<?php

namespace common\models\base;

use Yii;

/**
 * This is the model class for table "{{%edivi_order_card}}".
 *
 * @property int $id
 * @property int $edivi_credit_order_id
 * @property int $created_at
 * @property string $req_data
 * @property string $yearincome
 * @property int $card_count
 *
 * @property EdiviCreditOrder $ediviCreditOrder
 */
class EdiviOrderCard extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%edivi_order_card}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['edivi_credit_order_id', 'created_at', 'req_data', 'yearincome'], 'required'],
            [['edivi_credit_order_id', 'created_at', 'card_count'], 'integer'],
            [['req_data'], 'string'],
            [['yearincome'], 'number'],
            [['edivi_credit_order_id'], 'unique'],
            [['edivi_credit_order_id'], 'exist', 'skipOnError' => true, 'targetClass' => EdiviCreditOrder::className(), 'targetAttribute' => ['edivi_credit_order_id' => 'id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'edivi_credit_order_id' => Yii::t('app', 'Edivi Credit Order ID'),
            'created_at' => Yii::t('app', 'Created At'),
            'req_data' => Yii::t('app', 'Req Data'),
            'yearincome' => Yii::t('app', 'Yearincome'),
            'card_count' => Yii::t('app', 'Card Count'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getEdiviCreditOrder()
    {
        return $this->hasOne(EdiviCreditOrder::className(), ['id' => 'edivi_credit_order_id']);
    }
}
